load = {}

function setProxyArr(proxyObjArr) {
    for (let i = 0; i < proxyObjArr.length; i++) {
        const handler = `{
            get: function (target, property, receiver) {
                if (property != "__ZH_" && property !== "webpackChunkheifetz") {
                    console.log(
                        "方法:", "get",
                        "对象:", "${proxyObjArr[i]}",
                        "属性:", property,
                        "属性类型:", typeof property,
                        "属性值:", target[property],
                        "属性值类型:", typeof target[property]
                    );
                }
                return Reflect.get(...arguments);
            }
        }`;

        eval(`try {
            // 如果对象已存在，直接代理
            ${proxyObjArr[i]};
            ${proxyObjArr[i]} = new Proxy(${proxyObjArr[i]},${handler});
        } catch (e) {
            // 如果对象不存在，先初始化为空对象再代理
            ${proxyObjArr[i]} = {};
            ${proxyObjArr[i]} = new Proxy(${proxyObjArr[i]}, ${handler});
        }`);
    }
}

// 调用函数，代理全局对象 window
setProxyArr(["window","document","location","history","navigator","screen"]);

